package com.tanklab.signature.common.util.sm2Util;

import java.security.PrivateKey;
import java.security.PublicKey;
import java.util.Map;


/**
 * sm2算法应用演示
 */
public class Sm2Demo {

    static PublicKey publicKey = null;
    static PrivateKey privateKey = null;


//    public static void test() throws Exception {


    public static void main(String[] args) throws Exception {
        Map<String,String> keyMap = KeyUtils.generateSmKey();
        String pk = keyMap.get(KeyUtils.BASE_PUBLIC_KEY);
        System.out.println(pk);
        String sk = keyMap.get(KeyUtils.PRIVATE_KEY);
        String number = "13112341234";
        String password = "wangtongyang";

        String encryptNumber= Sm2.Encrypt(number,pk);
        String decryptNumber = Sm2.DecryptFromBase(encryptNumber,sk);
        String encryptPassword= Sm2.Encrypt(password,pk);
        String decryptPassword = Sm2.DecryptFromBase(encryptPassword,sk);

        System.out.println("Number密文："+encryptNumber);
        System.out.println("Number明文："+decryptNumber);
        System.out.println("Password密文："+encryptPassword);
        System.out.println("Password明文："+decryptPassword);
    }


}
